﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Document_Management.tianche;
//using Document_Management.刀具;
//using Document_Management.圖面;
//using Document_Management.庫存;
//using Document_Management.手工具;
//using Document_Management.文件;
//using Document_Management.登入;
//using Document_Management.車輛;
//using Document_Management.量具;
namespace Document_Management
{
    public partial class FrmDocMangnt : Form
    {
        static string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["庫存管理"].ConnectionString;
        int x, y, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9, x10, y10, x11, y11, x12, y12, x13, y13, x14, y14, x15, y15, x16, y16, x17, y17, x18, y18, x19, y19;
        int i = 29;
        string user, password, name, role;
        bool b圖面View, b圖面Search, b圖面Insert, b圖面Edit, b圖面Del,
              b文件View, b文件Search, b文件Insert, b文件Edit, b文件Del,
              b庫存View, b庫存Search, b庫存Insert, b庫存Edit, b庫存Del,
               b量具View, b量具Search, b量具Insert, b量具Edit, b量具Del,
              b刀具View, b刀具Search, b刀具Insert, b刀具Edit, b刀具Del,
              b手工具View, b手工具Search, b手工具Insert, b手工具Edit, b手工具Del,
               bNC程式View, bNC程式Search, bNC程式Insert, bNC程式Edit, bNC程式Del,
              b車輛View, b車輛Search, b車輛Insert, b車輛Edit, b車輛Del,
             b天車View, b天車Search, b天車Insert, b天車Edit, b天車Del,
             b登入View, b登入Search, b登入Insert, b登入Edit, b登入Del;
        // bool role;
        public FrmDocMangnt(string user, string password, string name,string role,
           bool  b圖面View, bool b圖面Search, bool b圖面Insert, bool b圖面Edit, bool b圖面Del,
             bool b文件View, bool b文件Search, bool b文件Insert, bool b文件Edit, bool b文件Del,
             bool b庫存View, bool b庫存Search, bool b庫存Insert, bool b庫存Edit, bool b庫存Del,
              bool b量具View, bool b量具Search, bool b量具Insert, bool b量具Edit, bool b量具Del,
             bool b刀具View, bool b刀具Search, bool b刀具Insert, bool b刀具Edit, bool b刀具Del,
             bool b手工具View, bool b手工具Search, bool b手工具Insert, bool b手工具Edit, bool b手工具Del,
              bool bNC程式View, bool bNC程式Search, bool bNC程式Insert, bool bNC程式Edit, bool bNC程式Del,
             bool b車輛View, bool b車輛Search, bool b車輛Insert, bool b車輛Edit, bool b車輛Del,
            bool b天車View, bool b天車Search, bool b天車Insert, bool b天車Edit,bool b天車Del,
            bool b登入View, bool b登入Search, bool b登入Insert, bool b登入Edit, bool b登入Del)
        {
            InitializeComponent();
            this.user = user;
            this.password = password;
            this.name = name;
            this.role = role;
            this.b圖面View=b圖面View;
            this.b圖面Search=b圖面Search;
            this.b圖面Insert=b圖面Insert;
            this.b圖面Edit=b圖面Edit;
            this.b圖面Del = b圖面Del;

            this.b文件View=b文件View;
            this.b文件Search=b文件Search;
            this.b文件Insert=b文件Insert;
            this.b文件Edit=b文件Edit;
            this.b文件Del=b文件Del;

            this.b庫存View=b庫存View; 
            this.b庫存Search=b庫存Search;
            this.b庫存Insert=b庫存Insert;
            this.b庫存Edit=b庫存Edit;
            this.b庫存Del=b庫存Del;

            this.b量具View=b量具View;
            this.b量具Search=b量具Search;
            this.b量具Insert=b量具Insert;
            this.b量具Edit=b量具Edit;
            this.b量具Del=b量具Del;

            this.b刀具View=b刀具View;
            this.b刀具Search=b刀具Search; 
            this.b刀具Insert=b刀具Insert;
            this.b刀具Edit=b刀具Edit;
            this.b刀具Del=b刀具Del;

            this.b手工具View=b手工具View;
            this.b手工具Search=b手工具Search; 
            this.b手工具Insert=b手工具Insert;
            this.b手工具Edit=b手工具Edit;
            this.b手工具Del=b手工具Del;

            this.bNC程式View=bNC程式View;
            this.bNC程式Search=bNC程式Search;
            this.bNC程式Insert=bNC程式Insert;
            this.bNC程式Edit=bNC程式Edit;
            this.bNC程式Del=bNC程式Del;

            this.b車輛View=b車輛View;
            this.b車輛Search=b車輛Search;
            this.b車輛Insert=b車輛Insert;
            this.b車輛Edit=b車輛Edit; 
            this.b車輛Del=b車輛Del;

            this.b天車View=b天車View;
            this.b天車Search=b天車Search;
            this.b天車Insert=b天車Insert; 
            this.b天車Edit=b天車Edit;
            this.b天車Del=b天車Del;

            this.b登入View=b登入View;
            this.b登入Search=b登入Search; 
            this.b登入Insert=b登入Insert;
            this.b登入Edit = b登入Edit;
            this.b登入Del = b登入Del;

        }

        private void DocMangnt_Load(object sender, EventArgs e)
        {
            
            lbuserlogin.Text = user + ",您好！";
            if (!b登入View) btn_登入管理.Visible = false;
            if (!b圖面View) btnImgMnt.Enabled = false;
            if(!b文件View)  btnDocMnt.Enabled = false;
            if(!b量具View) btn_量具台帳.Enabled = false;
            if (!b量具View)  btn_校正紀錄.Enabled = false;
            if (!b量具View)  btn_領用紀錄.Enabled = false;
            if (!b量具View)  btn_修理紀錄.Enabled = false;
            if (!b量具View)  btnjieyongjilu.Enabled = false;
            if (!b量具View)  btnSongjianjilu.Enabled = false;
            if (!b量具View)  btn報廢紀錄.Enabled = false;
            if(!b手工具View) btn_手工具台帳.Enabled = false;
            if (!b手工具View)  btn_領用紀錄_手工具.Enabled = false;
            if (!b手工具View)  btn_借用紀錄.Enabled = false;
            if (!b手工具View)  bt_維修紀錄.Enabled = false;
            if (!b手工具View)  bt_送檢紀錄.Enabled = false;
            if (!b手工具View)  bt_報廢紀錄.Enabled = false;
            if(!bNC程式View) btnNCcode.Enabled = false;
            if(!b車輛View) btnvehicle.Enabled = false;
            if(!b刀具View) btnCutMnt.Enabled = false;
            if(!b天車View) btnCraneMnt.Enabled = false;
            this.DesktopLocation = new Point(0, 0);
            //get old location
            x = btnAlready.Location.X;
            y = btnAlready.Location.Y;
            x1 = btn_量具台帳.Location.X;
            y1 = btn_量具台帳.Location.Y;
            x2 = btn_校正紀錄.Location.X;
            y2 = btn_校正紀錄.Location.Y;
            x3 = btn_領用紀錄.Location.X;
            y3 = btn_領用紀錄.Location.Y;

            x4 = btn_修理紀錄.Location.X;
            y4 = btn_修理紀錄.Location.Y;

            x5 = btnjieyongjilu.Location.X;
            y5 = btnjieyongjilu.Location.Y;

            x6 = btnSongjianjilu.Location.X;
            y6 = btnSongjianjilu.Location.Y;

            x7 = btn報廢紀錄.Location.X;
            y7 = btn報廢紀錄.Location.Y;

            x8 = btnManualMnt.Location.X;
            y8 = btnManualMnt.Location.Y;

            x9 = btn_手工具台帳.Location.X;
            y9 = btn_手工具台帳.Location.Y;

            x10 = btn_領用紀錄_手工具.Location.X;
            y10 = btn_領用紀錄_手工具.Location.Y;

            x11 = btn_借用紀錄.Location.X;
            y11 = btn_借用紀錄.Location.Y;

            x12 = btnNCcode.Location.X;
            y12 = btnNCcode.Location.Y;

            x13 = btnvehicle.Location.X;
            y13 = btnvehicle.Location.Y;

            x14 = btnCutMnt.Location.X;
            y14 = btnCutMnt.Location.Y;

            x15 = btnCraneMnt.Location.X;
            y15 = btnCraneMnt.Location.Y;

            x16 =bt_維修紀錄.Location.X;
            y16 =bt_維修紀錄.Location.Y;

            x17 = bt_送檢紀錄.Location.X;
            y17 = bt_送檢紀錄.Location.Y;

            x18 =bt_報廢紀錄.Location.X;
            y18 =bt_報廢紀錄.Location.Y;
            
            i = y15 - y14;

            this.btnAlready.Location = new System.Drawing.Point(x, y - 2 * i);
            btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 9 * i);
            btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 9 * i);
            btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 9 * i);
            btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 9 * i);
            btnNCcode.Location = new System.Drawing.Point(x12, y12 - 15 * i);
            btnvehicle.Location = new System.Drawing.Point(x13, y13 - 15 * i);
            btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 15 * i);
            btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 15 * i);
           
            btnImgMnt.Visible = false;
            btnDocMnt.Visible = false;
            btn_量具台帳.Visible = false;
            btn_校正紀錄.Visible = false;
            btn_領用紀錄.Visible = false;
            btn_修理紀錄.Visible = false;
            btnjieyongjilu.Visible = false;
            btnSongjianjilu.Visible = false;
            btn報廢紀錄.Visible = false;
            btn_手工具台帳.Visible = false;
            btn_領用紀錄_手工具.Visible = false;
            btn_借用紀錄.Visible = false;
            bt_維修紀錄.Visible = false;
            bt_送檢紀錄.Visible = false;
            bt_報廢紀錄.Visible = false;
            Loadwithcondition();
            Load_車輛_warn();
            Load_天車_warn();
        }
        public void Loadwithcondition()
        {
            SqlConnection con = new SqlConnection(connectionString);
            try
            {

                con.Open();

                //"SELECT pocet FROM klisluz " + 
                //                                  "WHERE id = @id",spojeni);
                SqlDataAdapter da = new SqlDataAdapter("sp_產品_須請購", con);
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                DataTable dt = new DataTable();
                da.Fill(dt);
                dataGridStocklist.DataSource = dt;
                PublicClass.setRowNumber(dataGridStocklist);
                dataGridStocklist.Columns[3].HeaderText = "現有庫" + "\n存量";
                dataGridStocklist.Columns[3].Width = 70;
                dataGridStocklist.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dataGridStocklist.Columns[4].Width = 70;

                dataGridStocklist.Columns[4].HeaderCell.Style.ForeColor = Color.Red;
                dataGridStocklist.Columns[4].DefaultCellStyle.ForeColor = Color.Red;
                dataGridStocklist.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                con.Close();
            }
            catch (Exception ex)
            {
                ;
                MessageBox.Show(ex.Message);
                con.Close();
            }


        }

        private void btnImgDocMnt_Click(object sender, EventArgs e)
        {
            if (btnImgDocMnt.Text == "(-)1. 圖文管理" && btnAlready.Text == "(+)2. 量具管理" && btnManualMnt.Text == "(+)3. 手工具管理")
            {
                btnImgDocMnt.Text = "(+)1. 圖文管理";
                btnImgMnt.Visible = false;
                btnDocMnt.Visible = false;
                this.btnAlready.Location = new System.Drawing.Point(x, y - 2 * i);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 9 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 9 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 9 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 9 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 15 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 15 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 15 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 15 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 15 * i);

            }
            else if (btnImgDocMnt.Text == "(-)1. 圖文管理" && btnAlready.Text == "(+)2. 量具管理" && btnManualMnt.Text == "(-)3. 手工具管理")
            {
                btnImgDocMnt.Text = "(+)1. 圖文管理";
                btnImgMnt.Visible = false;
                btnDocMnt.Visible = false;
                this.btnAlready.Location = new System.Drawing.Point(x, y - 2 * i);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 9 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 9 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 9 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 9 * i);
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 9 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 9 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 9 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 9 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 9 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 9 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 9 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 9 * i);
                //sua o day

            }
            else if (btnImgDocMnt.Text == "(-)1. 圖文管理" && btnAlready.Text == "(-)2. 量具管理" && btnManualMnt.Text == "(-)3. 手工具管理")
            {
                btnImgDocMnt.Text = "(+)1. 圖文管理";
                btnImgMnt.Visible = false;
                btnDocMnt.Visible = false;

                btn_量具台帳.Visible = true;
                btn_校正紀錄.Visible = true;
                btn_領用紀錄.Visible = true;
                btn_修理紀錄.Visible = true;
                btnjieyongjilu.Visible = true;
                btnSongjianjilu.Visible = true;
                btn報廢紀錄.Visible = true;
                this.btnAlready.Location = new System.Drawing.Point(x, y - 2 * i);
                this.btn_量具台帳.Location = new System.Drawing.Point(x1, y1 - 2 * i);
                this.btn_校正紀錄.Location = new System.Drawing.Point(x2, y2 - 2 * i);
                this.btn_領用紀錄.Location = new System.Drawing.Point(x3, y3 - 2 * i);
                this.btn_修理紀錄.Location = new System.Drawing.Point(x4, y4 - 2 * i);
                this.btnjieyongjilu.Location = new System.Drawing.Point(x5, y5 - 2 * i);
                this.btnSongjianjilu.Location = new System.Drawing.Point(x6, y6 - 2 * i);
                this.btn報廢紀錄.Location = new System.Drawing.Point(x7, y7 - 2 * i);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 2 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 2 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 2 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 2 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 2 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 2 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 2 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 2 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 2 * i);
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 2 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 2 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 2 * i);
                //sua o day

            }
            else if (btnImgDocMnt.Text == "(+)1. 圖文管理" && btnAlready.Text == "(+)2. 量具管理" && btnManualMnt.Text == "(-)3. 手工具管理")
            {
                btnImgDocMnt.Text = "(-)1. 圖文管理";
                btnImgMnt.Visible = true;
                btnDocMnt.Visible = true;
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 7 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 7 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 7 * i);
                btnAlready.Location = new System.Drawing.Point(x, y);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 7 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 7 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 7 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 7 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 7 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 7 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 7 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 7 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 7 * i);

            }
            else if (btnImgDocMnt.Text == "(+)1. 圖文管理" && btnAlready.Text == "(-)2. 量具管理" && btnManualMnt.Text == "(-)3. 手工具管理")
            {
                btnImgDocMnt.Text = "(-)1. 圖文管理";
                btnImgMnt.Visible = true;
                btnDocMnt.Visible = true;
                btn_量具台帳.Visible = true;
                btn_校正紀錄.Visible = true;
                btn_領用紀錄.Visible = true;
                btn_修理紀錄.Visible = true;
                btnjieyongjilu.Visible = true;
                btnSongjianjilu.Visible = true;
                btn報廢紀錄.Visible = true;
                this.btnAlready.Location = new System.Drawing.Point(x, y);
                this.btn_量具台帳.Location = new System.Drawing.Point(x1, y1);
                this.btn_校正紀錄.Location = new System.Drawing.Point(x2, y2);
                this.btn_領用紀錄.Location = new System.Drawing.Point(x3, y3);
                this.btn_修理紀錄.Location = new System.Drawing.Point(x4, y4);
                this.btnjieyongjilu.Location = new System.Drawing.Point(x5, y5);
                this.btnSongjianjilu.Location = new System.Drawing.Point(x6, y6);
                this.btn報廢紀錄.Location = new System.Drawing.Point(x7, y7);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11);
                btnNCcode.Location = new System.Drawing.Point(x12, y12);
                btnvehicle.Location = new System.Drawing.Point(x13, y13);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19);
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18);

            }
            else if (btnImgDocMnt.Text == "(+)1. 圖文管理" && btnAlready.Text == "(-)2. 量具管理" && btnManualMnt.Text == "(+)3. 手工具管理")
            {
                btnImgDocMnt.Text = "(-)1. 圖文管理";
                btnImgMnt.Visible = true;
                btnDocMnt.Visible = true;
                btn_量具台帳.Visible = true;
                btn_校正紀錄.Visible = true;
                btn_領用紀錄.Visible = true;
                btn_修理紀錄.Visible = true;
                btnjieyongjilu.Visible = true;
                btnSongjianjilu.Visible = true;
                btn報廢紀錄.Visible = true;
                this.btnAlready.Location = new System.Drawing.Point(x, y);
                this.btn_量具台帳.Location = new System.Drawing.Point(x1, y1);
                this.btn_校正紀錄.Location = new System.Drawing.Point(x2, y2);
                this.btn_領用紀錄.Location = new System.Drawing.Point(x3, y3);
                this.btn_修理紀錄.Location = new System.Drawing.Point(x4, y4);
                this.btnjieyongjilu.Location = new System.Drawing.Point(x5, y5);
                this.btnSongjianjilu.Location = new System.Drawing.Point(x6, y6);
                this.btn報廢紀錄.Location = new System.Drawing.Point(x7, y7);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 6 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 6 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 6 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 6 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 6 * i);
            }

            else if (btnImgDocMnt.Text == "(+)1. 圖文管理" && btnAlready.Text == "(+)2. 量具管理" && btnManualMnt.Text == "(+)3. 手工具管理")
            {

                btnImgDocMnt.Text = "(-)1. 圖文管理";
                btnImgMnt.Visible = true;
                btnDocMnt.Visible = true;
                btn_量具台帳.Visible = false;
                btn_校正紀錄.Visible = false;
                btn_領用紀錄.Visible = false;
                btn_修理紀錄.Visible = false;
                btnjieyongjilu.Visible = false;
                btnSongjianjilu.Visible = false;
                btn報廢紀錄.Visible = false;
                this.btnAlready.Location = new System.Drawing.Point(x, y);
                this.btn_量具台帳.Location = new System.Drawing.Point(x1, y1);
                this.btn_校正紀錄.Location = new System.Drawing.Point(x2, y2);
                this.btn_領用紀錄.Location = new System.Drawing.Point(x3, y3);
                this.btn_修理紀錄.Location = new System.Drawing.Point(x4, y4);
                this.btnjieyongjilu.Location = new System.Drawing.Point(x5, y5);
                this.btnSongjianjilu.Location = new System.Drawing.Point(x6, y6);
                this.btn報廢紀錄.Location = new System.Drawing.Point(x7, y7);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 7 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 7 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 7 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 7 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 13 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 13 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 13 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 13 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 13 * i);
            }

            else if (btnImgDocMnt.Text == "(-)1. 圖文管理" && btnAlready.Text == "(-)2. 量具管理" && btnManualMnt.Text == "(+)3. 手工具管理")
            {

                btnImgDocMnt.Text = "(+)1. 圖文管理";
                btnImgMnt.Visible = false;
                btnDocMnt.Visible = false;


                this.btnAlready.Location = new System.Drawing.Point(x, y - 2 * i);
                this.btn_量具台帳.Location = new System.Drawing.Point(x1, y1 - 2 * i);
                this.btn_校正紀錄.Location = new System.Drawing.Point(x2, y2 - 2 * i);
                this.btn_領用紀錄.Location = new System.Drawing.Point(x3, y3 - 2 * i);
                this.btn_修理紀錄.Location = new System.Drawing.Point(x4, y4 - 2 * i);
                this.btnjieyongjilu.Location = new System.Drawing.Point(x5, y5 - 2 * i);
                this.btnSongjianjilu.Location = new System.Drawing.Point(x6, y6 - 2 * i);
                this.btn報廢紀錄.Location = new System.Drawing.Point(x7, y7 - 2 * i);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 2 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 2 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 2 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 2 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 8 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 8 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 8 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 8 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 8 * i);
            }


        }


        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (!b庫存View)
            {
                MessageBox.Show("很抱歉，您沒有權限","錯誤",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                return;
            }
            frmStockMnt frm = new frmStockMnt(b庫存Search,b庫存Insert, b庫存Edit,b庫存Del);
            //frm.MdiParent = this;
            frm.ShowDialog();
            Loadwithcondition();
        }

        private void btnImgMnt_Click(object sender, EventArgs e)
        {
           
            frmImageMnt frm = new frmImageMnt(b圖面Search, b圖面Insert, b圖面Edit, b圖面Del);
            frm.ShowDialog();
        }

        private void btnDocMnt_Click(object sender, EventArgs e)
        {
           
            frmDocMnt frm = new frmDocMnt(b文件Search, b文件Insert, b文件Edit, b文件Del);
            frm.ShowDialog();
        }

        private void btnvehicle_Click(object sender, EventArgs e)
        {
           
            frmVehicleMnt frm = new frmVehicleMnt(b車輛Insert, b車輛Edit, b車輛Del, b車輛Search);
            frm.Show();
            Load_車輛_warn();
        }

        private void btnAlready_Click(object sender, EventArgs e)
        {
            if (btnAlready.Text == "(-)2. 量具管理" && btnImgDocMnt.Text == "(-)1. 圖文管理" && btnManualMnt.Text == "(+)3. 手工具管理")
            {
                btnAlready.Text = "(+)2. 量具管理";
                btn_量具台帳.Visible = false;
                btn_校正紀錄.Visible = false;
                btn_領用紀錄.Visible = false;
                btn_修理紀錄.Visible = false;
                btnjieyongjilu.Visible = false;
                btnSongjianjilu.Visible = false;
                btn報廢紀錄.Visible = false;
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 7 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 7 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 7 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 7 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 13 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 13 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 13 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 13 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 13 * i);
            }
            else if (btnAlready.Text == "(-)2. 量具管理" && btnImgDocMnt.Text == "(-)1. 圖文管理" && btnManualMnt.Text == "(-)3. 手工具管理")
            {
                btnAlready.Text = "(+)2. 量具管理";
                btn_量具台帳.Visible = false;
                btn_校正紀錄.Visible = false;
                btn_領用紀錄.Visible = false;
                btn_修理紀錄.Visible = false;
                btnjieyongjilu.Visible = false;
                btnSongjianjilu.Visible = false;
                btn報廢紀錄.Visible = false;
                btn報廢紀錄.Location = new System.Drawing.Point(x7, y7 - 7 * i);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 7 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 7 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 7 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 7 * i);

                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 7 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 7 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 7 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 7 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 7 * i);
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 7 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 7 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 7 * i);
            }
            else if (btnAlready.Text == "(+)2. 量具管理" && btnImgDocMnt.Text == "(-)1. 圖文管理" && btnManualMnt.Text == "(-)3. 手工具管理")
            {
                btnAlready.Text = "(-)2. 量具管理";
                btn_量具台帳.Visible = true;
                btn_校正紀錄.Visible = true;
                btn_領用紀錄.Visible = true;
                btn_修理紀錄.Visible = true;
                btnjieyongjilu.Visible = true;
                btnSongjianjilu.Visible = true;
                btn報廢紀錄.Visible = true;
                bt_維修紀錄.Visible = true;
                bt_送檢紀錄.Visible = true;
                bt_報廢紀錄.Visible = true;
                btn報廢紀錄.Location = new System.Drawing.Point(x7, y7);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11);
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18);
                btnNCcode.Location = new System.Drawing.Point(x12, y12);
                btnvehicle.Location = new System.Drawing.Point(x13, y13);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19);
            }
            else if (btnAlready.Text == "(-)2. 量具管理" && btnImgDocMnt.Text == "(+)1. 圖文管理" && btnManualMnt.Text == "(-)3. 手工具管理")
            {
                btnAlready.Text = "(+)2. 量具管理";
                btn_量具台帳.Visible = false;
                btn_校正紀錄.Visible = false;
                btn_領用紀錄.Visible = false;
                btn_修理紀錄.Visible = false;
                btnjieyongjilu.Visible = false;
                btnSongjianjilu.Visible = false;
                btn報廢紀錄.Visible = false;
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 9 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 9 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 9 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 9 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 9 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 9 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 9 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 9 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 9 * i);
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 9 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 9 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 9 * i);
            }
            else if (btnAlready.Text == "(+)2. 量具管理" && btnImgDocMnt.Text == "(-)1. 圖文管理" && btnManualMnt.Text == "(+)3. 手工具管理")
            {
                btnAlready.Text = "(-)2. 量具管理";
                btn_量具台帳.Visible = true;
                btn_校正紀錄.Visible = true;
                btn_領用紀錄.Visible = true;
                btn_修理紀錄.Visible = true;
                btnjieyongjilu.Visible = true;
                btnSongjianjilu.Visible = true;
                btn報廢紀錄.Visible = true;
                this.btnAlready.Location = new System.Drawing.Point(x, y);
                this.btn_量具台帳.Location = new System.Drawing.Point(x1, y1);
                this.btn_校正紀錄.Location = new System.Drawing.Point(x2, y2);
                this.btn_領用紀錄.Location = new System.Drawing.Point(x3, y3);
                this.btn_修理紀錄.Location = new System.Drawing.Point(x4, y4);
                this.btnjieyongjilu.Location = new System.Drawing.Point(x5, y5);
                this.btnSongjianjilu.Location = new System.Drawing.Point(x6, y6);
                this.btn報廢紀錄.Location = new System.Drawing.Point(x7, y7);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 6 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 6 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 6 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 6 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 6 * i);

            }
            else if (btnAlready.Text == "(+)2. 量具管理" && btnImgDocMnt.Text == "(+)1. 圖文管理" && btnManualMnt.Text == "(+)3. 手工具管理")
            {
                btnAlready.Text = "(-)2. 量具管理";
                btn_量具台帳.Visible = true;
                btn_校正紀錄.Visible = true;
                btn_領用紀錄.Visible = true;
                btn_修理紀錄.Visible = true;
                btnjieyongjilu.Visible = true;
                btnSongjianjilu.Visible = true;
                btn報廢紀錄.Visible = true;
                this.btnAlready.Location = new System.Drawing.Point(x, y - 2 * i);
                this.btn_量具台帳.Location = new System.Drawing.Point(x1, y1 - 2 * i);
                this.btn_校正紀錄.Location = new System.Drawing.Point(x2, y2 - 2 * i);
                this.btn_領用紀錄.Location = new System.Drawing.Point(x3, y3 - 2 * i);
                this.btn_修理紀錄.Location = new System.Drawing.Point(x4, y4 - 2 * i);
                this.btnjieyongjilu.Location = new System.Drawing.Point(x5, y5 - 2 * i);
                this.btnSongjianjilu.Location = new System.Drawing.Point(x6, y6 - 2 * i);
                this.btn報廢紀錄.Location = new System.Drawing.Point(x7, y7 - 2 * i);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 2 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 2 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 2 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 2 * i);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 2 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 8 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 8 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 8 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 8 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 8 * i);


            }
            else if (btnAlready.Text == "(+)2. 量具管理" && btnImgDocMnt.Text == "(+)1. 圖文管理" && btnManualMnt.Text == "(-)3. 手工具管理")
            {
                btnAlready.Text = "(-)2. 量具管理";
                btn_量具台帳.Visible = true;
                btn_校正紀錄.Visible = true;
                btn_領用紀錄.Visible = true;
                btn_修理紀錄.Visible = true;
                btnjieyongjilu.Visible = true;
                btnSongjianjilu.Visible = true;
                btn報廢紀錄.Visible = true;
                this.btnAlready.Location = new System.Drawing.Point(x, y - 2 * i);
                this.btn_量具台帳.Location = new System.Drawing.Point(x1, y1 - 2 * i);
                this.btn_校正紀錄.Location = new System.Drawing.Point(x2, y2 - 2 * i);
                this.btn_領用紀錄.Location = new System.Drawing.Point(x3, y3 - 2 * i);
                this.btn_修理紀錄.Location = new System.Drawing.Point(x4, y4 - 2 * i);
                this.btnjieyongjilu.Location = new System.Drawing.Point(x5, y5 - 2 * i);
                this.btnSongjianjilu.Location = new System.Drawing.Point(x6, y6 - 2 * i);
                this.btn報廢紀錄.Location = new System.Drawing.Point(x7, y7 - 2 * i);
                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 2 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 2 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 2 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 2 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 2 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 2 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 2 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 2 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 2 * i);
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 2 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 2 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 2 * i);


            }
            else if (btnAlready.Text == "(-)2. 量具管理" && btnImgDocMnt.Text == "(+)1. 圖文管理" && btnManualMnt.Text == "(+)3. 手工具管理")
            {
                btnAlready.Text = "(+)2. 量具管理";
                btn_量具台帳.Visible = false;
                btn_校正紀錄.Visible = false;
                btn_領用紀錄.Visible = false;
                btn_修理紀錄.Visible = false;
                btnjieyongjilu.Visible = false;
                btnSongjianjilu.Visible = false;
                btn報廢紀錄.Visible = false;

                btnManualMnt.Location = new System.Drawing.Point(x8, y8 - 9 * i);
                btn_手工具台帳.Location = new System.Drawing.Point(x9, y9 - 9 * i);
                btn_領用紀錄_手工具.Location = new System.Drawing.Point(x10, y10 - 9 * i);
                btn_借用紀錄.Location = new System.Drawing.Point(x11, y11 - 9 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 15 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 15 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 15 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 15 * i);
                //  //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 15 * i);
            }
           
        }


        private void btnCutMnt_Click(object sender, EventArgs e)
        {
           
            FrmCuttingtool_Manager frm = new FrmCuttingtool_Manager(b刀具Search, b刀具Insert, b刀具Edit, b刀具Del);
            frm.ShowDialog();
        }

        private void btnManualMnt_Click(object sender, EventArgs e)
        {
            if (btnManualMnt.Text == "(-)3. 手工具管理" && btnAlready.Text == "(+)2. 量具管理" && btnImgDocMnt.Text == "(+)1. 圖文管理")
            {
                btnManualMnt.Text = "(+)3. 手工具管理";
                btn_手工具台帳.Visible = false;
                btn_領用紀錄_手工具.Visible = false;
                btn_借用紀錄.Visible = false;
                bt_維修紀錄.Visible = false;
                bt_送檢紀錄.Visible = false;
                bt_報廢紀錄.Visible = false;

                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 15 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 15 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 15 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 15 * i);
                // //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 15 * i);
                //btnNCcode.Location = new System.Drawing.Point(x12, y12 -348);
            }
            else if (btnManualMnt.Text == "(+)3. 手工具管理" && btnAlready.Text == "(+)2. 量具管理" && btnImgDocMnt.Text == "(+)1. 圖文管理")
            {
                btnManualMnt.Text = "(-)3. 手工具管理";
                btn_手工具台帳.Visible = true;
                btn_領用紀錄_手工具.Visible = true;
                btn_借用紀錄.Visible = true;
                bt_維修紀錄.Visible = true;
                bt_送檢紀錄.Visible = true;
                bt_報廢紀錄.Visible = true;
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 9 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 9 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 9 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 9 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 9 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 9 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 9 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 9 * i);

            }
            else if (btnManualMnt.Text == "(+)3. 手工具管理" && btnAlready.Text == "(-)2. 量具管理" && btnImgDocMnt.Text == "(+)1. 圖文管理")
            {
                btnManualMnt.Text = "(-)3. 手工具管理";
                btn_手工具台帳.Visible = true;
                btn_領用紀錄_手工具.Visible = true;
                btn_借用紀錄.Visible = true;
                bt_維修紀錄.Visible = true;
                bt_送檢紀錄.Visible = true;
                bt_報廢紀錄.Visible = true;

                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 2 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 2 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 2 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 2 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 2 * i);
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 2 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 2 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 2 * i);

            }
            else if (btnManualMnt.Text == "(-)3. 手工具管理" && btnAlready.Text == "(-)2. 量具管理" && btnImgDocMnt.Text == "(+)1. 圖文管理")
            {
                btnManualMnt.Text = "(+)3. 手工具管理";
                btn_手工具台帳.Visible = false;
                btn_領用紀錄_手工具.Visible = false;
                btn_借用紀錄.Visible = false;
                bt_維修紀錄.Visible = false;
                bt_送檢紀錄.Visible = false;
                bt_報廢紀錄.Visible = false;
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 8 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 8 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 8 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 8 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 8 * i);


            }
            else if (btnManualMnt.Text == "(+)3. 手工具管理" && btnAlready.Text == "(+)2. 量具管理" && btnImgDocMnt.Text == "(-)1. 圖文管理")
            {
                btnManualMnt.Text = "(-)3. 手工具管理";
                btn_手工具台帳.Visible = true;
                btn_領用紀錄_手工具.Visible = true;
                btn_借用紀錄.Visible = true;
                bt_維修紀錄.Visible = true;
                bt_送檢紀錄.Visible = true;
                bt_報廢紀錄.Visible = true;
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16 - 7 * i);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17 - 7 * i);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18 - 7 * i);
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 7 * i);//4 nut cuoi
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 7 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 7 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 7 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 7 * i);

            }
            else if (btnManualMnt.Text == "(-)3. 手工具管理" && btnAlready.Text == "(+)2. 量具管理" && btnImgDocMnt.Text == "(-)1. 圖文管理")
            {
                btnManualMnt.Text = "(+)3. 手工具管理";
                btn_手工具台帳.Visible = false;
                btn_領用紀錄_手工具.Visible = false;
                btn_借用紀錄.Visible = false;
                bt_維修紀錄.Visible = false;
                bt_送檢紀錄.Visible = false;
                bt_報廢紀錄.Visible = false;
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 13 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 13 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 13 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 13 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 13 * i);

            }
            else if (btnManualMnt.Text == "(+)3. 手工具管理" && btnAlready.Text == "(-)2. 量具管理" && btnImgDocMnt.Text == "(-)1. 圖文管理")
            {
                btnManualMnt.Text = "(-)3. 手工具管理";
                btn_手工具台帳.Visible = true;
                btn_領用紀錄_手工具.Visible = true;
                btn_借用紀錄.Visible = true;
                bt_維修紀錄.Visible = true;
                bt_送檢紀錄.Visible = true;
                bt_報廢紀錄.Visible = true;
                bt_維修紀錄.Location = new System.Drawing.Point(x16, y16);
                bt_送檢紀錄.Location = new System.Drawing.Point(x17, y17);
                bt_報廢紀錄.Location = new System.Drawing.Point(x18, y18);

                btnNCcode.Location = new System.Drawing.Point(x12, y12);
                btnvehicle.Location = new System.Drawing.Point(x13, y13);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19);
                //btnNCcode.Location = new System.Drawing.Point(x12, y12 -9*i);
            }
            else if (btnManualMnt.Text == "(-)3. 手工具管理" && btnAlready.Text == "(-)2. 量具管理" && btnImgDocMnt.Text == "(-)1. 圖文管理")
            {
                btnManualMnt.Text = "(+)3. 手工具管理";
                btn_手工具台帳.Visible = false;
                btn_領用紀錄_手工具.Visible = false;
                btn_借用紀錄.Visible = false;
                bt_維修紀錄.Visible = false;
                bt_送檢紀錄.Visible = false;
                bt_報廢紀錄.Visible = false;
                btnNCcode.Location = new System.Drawing.Point(x12, y12 - 6 * i);
                btnvehicle.Location = new System.Drawing.Point(x13, y13 - 6 * i);
                btnCutMnt.Location = new System.Drawing.Point(x14, y14 - 6 * i);
                btnCraneMnt.Location = new System.Drawing.Point(x15, y15 - 6 * i);
                //btn記錄領用.Location = new System.Drawing.Point(x19, y19 - 6 * i);
                //btnNCcode.Location = new System.Drawing.Point(x12, y12 -9*i);
            }
        }

        private void btnNCcode_Click(object sender, EventArgs e)
        {
            
            frmNC frm = new frmNC(bNC程式Search, bNC程式Insert, bNC程式Edit, bNC程式Del);
            frm.ShowDialog();
        }

        private void btnCraneMnt_Click(object sender, EventArgs e)
        {
            
            main frm = new main(b天車Search, b天車Insert, b天車Edit, b天車Del);
            frm.ShowDialog();
        }

        private void dataGridStocklist_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            PublicClass.setRowNumber(dataGridStocklist);
        }

        private void btnreload_Click(object sender, EventArgs e)
        {
            Loadwithcondition();
        }

        private void btn_changePass_Click(object sender, EventArgs e)
        {
            try
            {
                frmChangePass frm = new frmChangePass(user, password, name, role);
                frm.ShowDialog();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }

        }

        private void btn_exit_Click(object sender, EventArgs e)
        {
            try
            {
                this.Hide();
                FrmLogin frm = new FrmLogin();
                frm.ShowDialog();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            //this.Close();
        }

        //private voidbt_維修紀錄_Click(object sender, EventArgs e)
        //{
        //    frmLoginMagnt frm = new frmLoginMagnt(b登入Search, b登入Insert, b登入Edit, b登入Del);
        //    frm.ShowDialog();
        //}

        private void btn_量具台帳_Click(object sender, EventArgs e)
        {
           
            frm量具台帳 frm = new frm量具台帳(b量具Search, b量具Insert, b量具Edit, b量具Del);
            frm.ShowDialog();
        }

        private void btn_校正紀錄_Click(object sender, EventArgs e)
        {
            
            frmJiaozhengjilu frm = new frmJiaozhengjilu(b量具Search, b量具Insert, b量具Edit, b量具Del);
            frm.ShowDialog();
        }

        private void btn_領用紀錄_Click(object sender, EventArgs e)
        {
            
            frmlingyongjilu frm = new frmlingyongjilu(b量具Search, b量具Insert, b量具Edit, b量具Del);
            frm.ShowDialog();
        }

        private void btn_修理紀錄_Click(object sender, EventArgs e)
        {
           
            frmxiulijilu frm = new frmxiulijilu(b量具Search, b量具Insert, b量具Edit, b量具Del);
            frm.ShowDialog();
        }

        private void btnjieyongjilu_Click(object sender, EventArgs e)
        {
           
            frmjieyongjilu frm = new frmjieyongjilu(b量具Search, b量具Insert, b量具Edit, b量具Del);
            frm.ShowDialog();
        }

        private void btnSongjianjilu_Click(object sender, EventArgs e)
        {
            
            frmSongjianjilu frm = new frmSongjianjilu(b量具Search, b量具Insert, b量具Edit, b量具Del);
            frm.ShowDialog();
        }

        private void btn修理紀錄_Click(object sender, EventArgs e)
        {
            frmxiulijilu frm = new frmxiulijilu(b量具Search, b量具Insert, b量具Edit, b量具Del);
            frm.ShowDialog();

        }

        private void btn報廢紀錄_Click(object sender, EventArgs e)
        {
           
            frmbaofeijilu frm = new frmbaofeijilu(b量具Search, b量具Insert, b量具Edit, b量具Del);
            frm.ShowDialog();
        }


        private void FrmDocMangnt_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void bt_維修紀錄_Click(object sender, EventArgs e)
        {
           
            ManualTool_Weixiu frm = new ManualTool_Weixiu("維修", b手工具Search, b手工具Insert, b手工具Edit, b手工具Del);
            frm.ShowDialog();
        }

        private void bt_送檢紀錄_Click(object sender, EventArgs e)
        {
           
            ManualTool_Weixiu frm = new ManualTool_Weixiu("送檢", b手工具Search, b手工具Insert, b手工具Edit, b手工具Del);
            frm.ShowDialog();
        }

        private void bt_報廢紀錄_Click(object sender, EventArgs e)
        {
           
            ManualTool_Weixiu frm = new ManualTool_Weixiu("報廢", b手工具Search, b手工具Insert, b手工具Edit, b手工具Del);
            frm.ShowDialog();
        }

        private void btn_領用紀錄_手工具_Click(object sender, EventArgs e)
        {
           
            ManualToolMnt_Use frm = new ManualToolMnt_Use(b手工具Search, b手工具Insert, b手工具Edit, b手工具Del);
            frm.ShowDialog();
        }

        private void btn_借用紀錄_Click(object sender, EventArgs e)
        {
            
            ManualToolMnt_Borrow frm = new ManualToolMnt_Borrow(b手工具Search, b手工具Insert, b手工具Edit, b手工具Del);
            frm.ShowDialog();
        }

        private void btn_手工具台帳_Click(object sender, EventArgs e)
        {
            
            ManualToolMnt frm = new ManualToolMnt(b手工具Search, b手工具Insert, b手工具Edit, b手工具Del);
            frm.ShowDialog();
        }

        public void Load_車輛_warn()
        {
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter("sp_車輛_warn", con);
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                DataTable dt = new DataTable();
                da.Fill(dt);
                dataGrid_warn.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                dataGrid_warn.DataSource = dt;
                dataGrid_warn.EnableHeadersVisualStyles = false;
                dataGrid_warn.ColumnHeadersDefaultCellStyle.BackColor = Color.Cyan;
                //dataGrid_車輛.ColumnHeadersDefaultCellStyle.Font
                dataGrid_warn.Columns[4].HeaderCell.Style.ForeColor = Color.Red;
                dataGrid_warn.Columns[4].DefaultCellStyle.ForeColor = Color.Red;
                PublicClass.setRowNumber(dataGrid_warn);
                con.Close();
                //
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                con.Close();
            }
        }

        public void Load_天車_warn()
        {
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter("sp_天車_warn", con);
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                DataTable dt = new DataTable();
                da.Fill(dt);
                dataGrid_warn2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                dataGrid_warn2.DataSource = dt;
                dataGrid_warn2.EnableHeadersVisualStyles = false;
                dataGrid_warn2.ColumnHeadersDefaultCellStyle.BackColor = Color.Cyan;
                //dataGrid_車輛.ColumnHeadersDefaultCellStyle.Font
                dataGrid_warn2.Columns[4].HeaderCell.Style.ForeColor = Color.Red;
                dataGrid_warn2.Columns[4].DefaultCellStyle.ForeColor = Color.Red;
                PublicClass.setRowNumber(dataGrid_warn2);
                con.Close();
                //
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                con.Close();
            }
        }

        private void btn_登入管理_Click(object sender, EventArgs e)
        {
                
            frmLoginMagnt frm = new frmLoginMagnt(b登入Search, b登入Insert, b登入Edit, b登入Del);
            frm.ShowDialog();
        }

        private void tabCtrl_待辦_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabCtrl_待辦.SelectedIndex == 1)
            {
                Load_車輛_warn();
                PublicClass.setRowNumber(dataGrid_warn);
            }
            if (tabCtrl_待辦.SelectedIndex == 2)
            {
                Load_天車_warn();
                PublicClass.setRowNumber(dataGrid_warn2);
            }
        }

        private void tab2天車保養提示_Click(object sender, EventArgs e)
        {

        }
    }
}
